{
  LW CustObj -- LightWave Custom Objects

  This unit defines the types and macros for simple DynaTypes.

  Based on lwcustobj.h which is:
  Copyright 1999, NewTek, Inc.
}

{
  Copyright 2012, Jameel Halabi

  This unit is part of the BlaiseWave wrapper,
  which is licensed under the BSD 2-Clause license (see licenses/license.txt).
}


unit LW_CustObj;

{$mode delphi}{$H+}

interface

uses
  LW_Handler,
  LW_Render ,
  LW_Types  ;

const
  LWCUSTOMOBJ_HCLASS  = 'CustomObjHandler';
  LWCUSTOMOBJ_ICLASS  = 'CustomObjInterface';
  LWCUSTOMOBJ_GCLASS  = 'CustomObjGizmo';
  LWCUSTOMOBJ_VERSION = 5;

  LWVIEW_ZY     = 0;
  LWVIEW_XZ     = 1;
  LWVIEW_XY     = 2;
  LWVIEW_PERSP  = 3;
  LWVIEW_LIGHT  = 4;
  LWVIEW_CAMERA = 5;
  LWVIEW_SCHEMA = 6;

  LWCOFL_SELECTED       = 1 shl 0;
  LWCOFL_PICKING        = 1 shl 1;
  LWCOFL_NO_DEPTH_WRITE = 1 shl 2;

  LWLPAT_SOLID   = 0;
  LWLPAT_DOT     = 1;
  LWLPAT_DASH    = 2;
  LWLPAT_LONGDOT = 3;

  LWCSYS_WORLD    = 0;
  LWCSYS_OBJECT   = 1;
  LWCSYS_ICON     = 2;
  LWCSYS_VIEWPORT = 3;

  LWJUST_LEFT   = 0;
  LWJUST_CENTER = 1;
  LWJUST_RIGHT  = 2;

  LWDRAWMODE_CULLFACE   = 1 shl 0;
  LWDRAWMODE_OUTLINE    = 1 shl 1;
  LWDRAWMODE_DEPTHTEST  = 1 shl 2;
  LWDRAWMODE_DEPTHWRITE = 1 shl 3;

  LWCOF_SCHEMA_OK       = 1 shl 0;
  LWCOF_VIEWPORT_INDEX  = 1 shl 1;
  LWCOF_NO_DEPTH_BUFFER = 1 shl 2;
  LWCOF_OVERLAY         = 1 shl 3;
  LWCOF_XRAY            = 1 shl 4;

type
  PLWCustomObjAccess = ^TLWCustomObjAccess;
  TLWCustomObjAccess = record
    View        : Integer;
    Flags       : Integer;
    DispData    : Pointer;

    SetColor    : procedure
                  (      DispData           : Pointer            ;
                         RGBA               : TLWFVector4        ) ;
    SetPattern  : procedure
                  (      DispData           : Pointer            ;
                         LPat               : Integer            ) ;
    SetTexture  : procedure
                  (      DispData           : Pointer            ;
                         Size               : Integer            ;
                         ImageBytes         : PByte              ) ;
    SetUVs      : procedure
                  (      DispData           : Pointer            ;
                         UV0, UV1, UV2, UV3 : TLWDVector2        ) ;
    Point       : procedure
                  (      DispData           : Pointer            ;
                         XYZ                : TLWDVector         ;
                         CSys               : Integer            ) ;
    Line        : procedure
                  (      DispData           : Pointer            ;
                         End1, End2         : TLWDVector         ;
                         CSys               : Integer            ) ;
    Triangle    : procedure
                  (      DispData           : Pointer            ;
                         V1, V2, V3         : TLWDVector         ;
                         CSys               : Integer            ) ;
    Quad        : procedure
                  (      DispData           : Pointer            ;
                         V1, V2, V3, V4     : TLWDVector         ;
                         CSys               : Integer            ) ;
    Circle      : procedure
                  (      DispData           : Pointer            ;
                         Center             : TLWDVector         ;
                         Radius             : Double             ;
                         CSys               : Integer            ) ;
    Text        : procedure
                  (      DispData           : Pointer            ;
                         Pos                : TLWDVector         ;
                   const TextLine           : PChar              ;
                         Just               : Integer            ;
                         CSys               : Integer            ) ;

    ViewPos     ,
    ViewDir     : TLWDVector;

    SetCSysItem : procedure
                  (      DispData           : Pointer            ;
                         Item               : PLWItem            ) ;
    Polygon     : procedure
                  (      DispData           : Pointer            ;
                         NumV               : UInt32             ;
                         Vertices           : array of TLWDVector;
                         CSys               : Integer            ) ;
    PolyIndexed : procedure
                  (      DispData           : Pointer            ;
                         NumV               : UInt32             ;
                         Indices            : array of UInt32    ;
                         Vertices           : array of TLWDVector;
                         CSys               : Integer            ) ;
    SetDrawMode : procedure
                  (      DispData           : Pointer            ;
                         Mode               : UInt32             ) ;
    Disk        : procedure
                  (      DispData           : Pointer            ;
                         Center             : TLWDVector         ;
                         Radius             : Double             ;
                         CSys               : Integer            ) ;
    SetPart     : procedure
                  (      DispData           : Pointer            ;
                         Part               : UInt32             ) ;
  end;

  PLWCustomObjHandler = ^TLWCustomObjHandler;
  TLWCustomObjHandler = record
    Inst     : PLWInstanceFuncs;
    Item     : PLWItemFuncs    ;
    Rend     : PLWRenderFuncs  ;

    Evaluate : procedure
               (      Instance : PLWInstance       ;
                const Access   : PLWCustomObjAccess) ;
    Flags    : function
               (      Instance : PLWInstance       ) : UInt32;
  end;

implementation

end.

